﻿<navigation:Page x:Class="ExampleApplication.Examples.DataBinding" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="DataBinding Page"
           xmlns:sdk="clr-namespace:System.Windows;assembly=System.Windows.Controls"
           xmlns:deepearth="http://deepearth.codeplex.com/xaml"
           xmlns:nearmap ="clr-namespace:DeepEarth.Map.TileSources;assembly=DeepEarth.TileSources.NearMap"                   
                 >
    <Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <deepearth:DoubleCollectionConverter x:Key="doubleCollectionConverter"></deepearth:DoubleCollectionConverter>
            <deepearth:GeoItems x:Name="geoItems"></deepearth:GeoItems>

            <deepearth:TemplateSelector x:Key="mapTemplateSelector">
                <DataTemplate  deepearth:TemplateSelector.DataType="ExampleApplication.Examples.MyPointItem, ExampleApplication">
                    <deepearth:Pushpin Fill="{Binding Color}" Position="{Binding Position}" PositionOrigin="{Binding PositionOrigin}">
                    </deepearth:Pushpin>
                </DataTemplate>

                <sdk:HierarchicalDataTemplate ItemsSource="{Binding NestedItems}" deepearth:TemplateSelector.DataType="ExampleApplication.Examples.MyHierarchicalItem, ExampleApplication">
                </sdk:HierarchicalDataTemplate>

                <DataTemplate  deepearth:TemplateSelector.DataType="ExampleApplication.Examples.MyLineItem, ExampleApplication">
                    <deepearth:LineString Locations="{Binding Locations}" Stroke="{Binding Stroke}" StrokeThickness="{Binding StrokeThickness}" StrokeDashArray="{Binding StrokeDashArray, Converter={StaticResource doubleCollectionConverter}}">
                    </deepearth:LineString>
                </DataTemplate>

                <DataTemplate  deepearth:TemplateSelector.DataType="ExampleApplication.Examples.MyPolyItem, ExampleApplication">
                    <deepearth:Polygon OuterRing="{Binding Locations}" StrokeThickness="2" Stroke="{Binding Stroke}" Fill="{Binding Fill}" Opacity="0.3">
                    </deepearth:Polygon>
                </DataTemplate>

            </deepearth:TemplateSelector>

            <deepearth:TemplateSelector x:Key="layerTemplateSelector">

                <DataTemplate  deepearth:TemplateSelector.DataType="ExampleApplication.Examples.MyGroup, ExampleApplication">
                    <TextBlock Text="{Binding Name}" Foreground="White"></TextBlock>
                </DataTemplate>
                
                <DataTemplate  deepearth:TemplateSelector.DataType="ExampleApplication.Examples.MyBaseItem, ExampleApplication">
                    <TextBlock Text="{Binding Name}" Foreground="White"></TextBlock>
                </DataTemplate>
            </deepearth:TemplateSelector>
            
            <deepearth:TemplateSelector x:Key="labelTemplateSelector">
                <DataTemplate  deepearth:TemplateSelector.DataType="ExampleApplication.Examples.MyBaseItem, ExampleApplication">
                    <Border CornerRadius="5" Background="BlueViolet" Opacity="0.8">
                        <TextBlock Text="{Binding Name}" Foreground="White"></TextBlock>
                    </Border>
                </DataTemplate>
            </deepearth:TemplateSelector>

        </Grid.Resources>
        <Grid.ColumnDefinitions>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition Width="250"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        
        <deepearth:Map x:Name="map" GeoItems="{StaticResource geoItems}" TemplateSelector="{StaticResource mapTemplateSelector}" LabelTemplateSelector="{StaticResource labelTemplateSelector}">
            <deepearth:Map.View>
                <deepearth:MapView>
                    <deepearth:MapView.TileSourceProvider>
                        <nearmap:NearMapTileSourceProvider Mode="PhotoMap"></nearmap:NearMapTileSourceProvider>
                    </deepearth:MapView.TileSourceProvider>
                </deepearth:MapView>
            </deepearth:Map.View>

        </deepearth:Map>
        <deepearth:NavigationPanel Map="{Binding ElementName=map}"/>
        <deepearth:CoordinatePanel Map="{Binding ElementName=map}" VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
        <deepearth:ReorderableLayerPanel Grid.Column="1" GeoItems="{StaticResource geoItems}" TemplateSelector="{StaticResource layerTemplateSelector}"/>
    </Grid>
</navigation:Page>
